{
  description = "A simple NixOS flake";

  inputs = {
    # NixOS 官方软件源，这里使用 nixos-24.11 分支 unstable
    # nixpkgs.url = "github:NixOS/nixpkgs/nixos-24.11"; 
    nixpkgs.url = "github:NixOS/nixpkgs/nixos-unstable";
    # nixpkgs.url = "https://mirrors.ustc.edu.cn/nix-channels/nixos-24.11/nixexprs.tar.xz";
    home-manager = {
      url = "github:nix-community/home-manager";
      # The `follows` keyword in inputs is used for inheritance.
      # Here, `inputs.nixpkgs` of home-manager is kept consistent with
      # the `inputs.nixpkgs` of the current flake,
      # to avoid problems caused by different versions of nixpkgs.
      inputs.nixpkgs.follows = "nixpkgs";
    };
  };



  outputs = inputs@{ nixpkgs, home-manager, ... }: {
    nixosConfigurations = {
      # 主机配置
      ifnk-pc = nixpkgs.lib.nixosSystem {
        system = "x86_64-linux";
        modules = [
          # 系统配置
          ./configuration.nix
          
          # 将overlays应用到nixpkgs
          {
            nixpkgs.overlays = import ./overlays { pkgs = nixpkgs; inherit (nixpkgs) lib; };

          }

          # 将 home-manager 配置为 nixos 的一个 module
          # 这样在 nixos-rebuild switch 时，home-manager 配置也会被自动部署
          home-manager.nixosModules.home-manager
          {
            home-manager.useGlobalPkgs = true;
            home-manager.useUserPackages = true;

            # 使用模块化的用户配置
            home-manager.users.ifnk = import ./home.nix;

            # 使用 home-manager.extraSpecialArgs 自定义传递给 ./home.nix 的参数
            home-manager.extraSpecialArgs = inputs;
          }
        ];
      };
    };
  };
}
